package com.fira.edu.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.fira.common.utils.DateUtils;
import com.fira.common.utils.bean.DozerUtils;
import com.fira.common.utils.uuid.IdUtils;
import com.fira.edu.domain.dto.CourseScheduleTimeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fira.edu.mapper.EduCourseScheduleTimeMapper;
import com.fira.edu.domain.EduCourseScheduleTime;
import com.fira.edu.service.IEduCourseScheduleTimeService;
import com.fira.common.core.text.Convert;

/**
 * 排课上课时间安排Service业务层处理
 * 
 * @author zhushuyong
 * @date 2021-10-13
 */
@Service
public class EduCourseScheduleTimeServiceImpl implements IEduCourseScheduleTimeService 
{
    @Autowired
    private EduCourseScheduleTimeMapper eduCourseScheduleTimeMapper;

    /**
     * 查询排课上课时间安排
     * 
     * @param id 排课上课时间安排ID
     * @return 排课上课时间安排
     */
    @Override
    public EduCourseScheduleTime selectEduCourseScheduleTimeById(String id)
    {
        return eduCourseScheduleTimeMapper.selectEduCourseScheduleTimeById(id);
    }

    /**
     * 查询排课上课时间安排列表
     * 
     * @param eduCourseScheduleTime 排课上课时间安排
     * @return 排课上课时间安排
     */
    @Override
    public List<EduCourseScheduleTime> selectEduCourseScheduleTimeList(EduCourseScheduleTime eduCourseScheduleTime)
    {
        return eduCourseScheduleTimeMapper.selectEduCourseScheduleTimeList(eduCourseScheduleTime);
    }

    /**
     * 新增排课上课时间安排
     * 
     * @param eduCourseScheduleTime 排课上课时间安排
     * @return 结果
     */
    @Override
    public int insertEduCourseScheduleTime(EduCourseScheduleTime eduCourseScheduleTime)
    {
        eduCourseScheduleTime.setCreateTime(DateUtils.getNowDate());
        return eduCourseScheduleTimeMapper.insertEduCourseScheduleTime(eduCourseScheduleTime);
    }

    /**
     * 批量新增排课上课时间安排
     *
     * @param courseScheduleTimeDTOList
     * @return
     */
    @Override
    public int batchInsert(List<CourseScheduleTimeDTO> courseScheduleTimeDTOList) {
        List<EduCourseScheduleTime> courseScheduleTimeList = new ArrayList<>();
        courseScheduleTimeDTOList.forEach(item -> {
            EduCourseScheduleTime eduCourseScheduleTime = DozerUtils.copyProperties(item,EduCourseScheduleTime.class);
            eduCourseScheduleTime.setId(IdUtils.fastSimpleUUID());
            eduCourseScheduleTime.setCreateTime(DateUtils.getNowDate());
            courseScheduleTimeList.add(eduCourseScheduleTime);
        });
        return eduCourseScheduleTimeMapper.batchInsert(courseScheduleTimeList);
    }

    /**
     * 修改排课上课时间安排
     * 
     * @param eduCourseScheduleTime 排课上课时间安排
     * @return 结果
     */
    @Override
    public int updateEduCourseScheduleTime(EduCourseScheduleTime eduCourseScheduleTime)
    {
        eduCourseScheduleTime.setUpdateTime(DateUtils.getNowDate());
        return eduCourseScheduleTimeMapper.updateEduCourseScheduleTime(eduCourseScheduleTime);
    }

    /**
     * 删除排课上课时间安排对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteEduCourseScheduleTimeByIds(String ids)
    {
        return eduCourseScheduleTimeMapper.deleteEduCourseScheduleTimeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除排课上课时间安排信息
     * 
     * @param id 排课上课时间安排ID
     * @return 结果
     */
    @Override
    public int deleteEduCourseScheduleTimeById(String id)
    {
        return eduCourseScheduleTimeMapper.deleteEduCourseScheduleTimeById(id);
    }

    /**
     * 查询所有course_date为空的数据
     *
     * @return
     */
    @Override
    public List<EduCourseScheduleTime> selectScheduleTimeList4NullCourseDate() {
        return eduCourseScheduleTimeMapper.selectScheduleTimeList4NullCourseDate();
    }
}
